<?php
declare (strict_types=1);

namespace app\common\exception;

use think\facade\Env;

/**
 * Logic层异常
 */
class DomainInvalidException extends \RuntimeException
{
    protected $error;
    protected $debugError;

    public function __construct($error, $debugError = null)
    {
        $this->error      = $error;
        $this->debugError = is_null($debugError) ? $error : $debugError;
        $this->message    = is_array($error) ? implode(PHP_EOL, $error) : $error;
    }

    /**
     * 获取验证错误信息
     *
     * @access public
     * @return array|string
     */
    public function getError()
    {
        return Env::get('app_debug') ? $this->debugError : $this->error;
    }
}
